//
//  InformationShareView.m
//  artExamAssistant
//
//  Created by 李园园 on 15/12/18.
//  Copyright © 2015年 北京知远信息科技有限公司. All rights reserved.
//

#import "InformationShareView.h"



#define Button_Width  50
#define MainScreenSizeWidth     [UIScreen mainScreen].bounds.size.width
#define MainScreenSizeHeight    [UIScreen mainScreen].bounds.size.height

@interface InformationShareView ()

@property (nonatomic , strong)NSArray  *nameArr;
@property (nonatomic , strong)NSArray  *iconArr;
@property (nonatomic , strong)UILabel  *title;

@end
@implementation InformationShareView


- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        
        self.backgroundColor = [UIColor whiteColor];
        _nameArr = [[NSArray alloc]init];
        _iconArr = [[NSArray alloc]init];
        
        _nameArr = @[@"微信",@"朋友圈",@"QQ",@"空间"];
        
        _iconArr = @[@"logo_wechat",@"logo_wechatmoments",@"logo_qq",@"logo_qzone"];
        
        for (int i = 0 ; i < _nameArr.count; i ++) {
            CGFloat margin   =  (MainScreenSizeWidth -Button_Width*_nameArr.count)/(_nameArr.count+1);
            
            UIButton *shareBtn = [UIButton buttonWithType:UIButtonTypeCustom];
            [shareBtn setBackgroundImage:[UIImage imageNamed:_iconArr[i]] forState:UIControlStateNormal];
            shareBtn.tag = 6000+i;
            shareBtn.frame = CGRectMake(margin + (Button_Width+margin)*i, 40 , Button_Width, Button_Width);
            [shareBtn addTarget:self  action:@selector(didClickShareButonWithTag:) forControlEvents:UIControlEventTouchUpInside];
            [self addSubview:shareBtn];
            
            UILabel *appName = [[UILabel alloc]initWithFrame:CGRectMake(margin + (Button_Width+margin)*i, 40+Button_Width+10, Button_Width, 20)];
            appName.font = [UIFont systemFontOfSize:14];
            appName.textColor =[UIColor blackColor];
            appName.textAlignment = NSTextAlignmentCenter;
            appName.text = _nameArr[i];
            
            [self addSubview:appName];
        
    }

    UIButton *cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    cancelBtn.frame = CGRectMake(0, self.frame.size.height-39, MainScreenSizeWidth, 40);
    [cancelBtn setTitle:@"取消" forState:UIControlStateNormal];
    [cancelBtn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
        cancelBtn.layer.borderWidth=0.5;
        cancelBtn.layer.borderColor=[UIColor grayColor].CGColor;
    
    cancelBtn.clipsToBounds = YES;
    [cancelBtn addTarget:self action:@selector(didclickCancleBtn) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:cancelBtn];

    }
    
    
    return self;


}

- (void)didClickShareButonWithTag:(UIButton *)sender
{
    
    if ([self.delegate respondsToSelector:@selector(shareAppWithTag:)]) {
        [self.delegate shareAppWithTag:sender.tag];
    }
    
}


- (void)didclickCancleBtn
{
    if ([self.delegate respondsToSelector:@selector(didClickCancleButtonInBottomView)]) {
        [self.delegate didClickCancleButtonInBottomView];
    }
    
}





/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
